using System;
using System.Collections.Generic;

namespace SCG.General
{
    public static class RatingCalculator
    {
        public static double CalculateRating(double r1, double r2, bool won, double k = 32.0, double minRating = 500.0)
        {
            double e1 = 1.0 / (1.0 + (Math.Pow(10.0, (r2 - r1) / 400.0)));
            double newR1 = won ? r1 + k * 1.0 - k * e1 : r1 + k * 0.0 - k * e1;
            if (newR1 < minRating)
                newR1 = minRating;
            return newR1;
        }
    }
}
